package com.xd.cloud.dao.core;

import com.xd.cloud.dao.BaseDao;
import com.xd.cloud.dao.Page;
import com.xd.cloud.entity.core.Menu;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author wangtao
 * @class_name MenuDao
 * @description 菜单数据dao层
 * @create 2017/12/19
 */
@Repository
public class MenuDao extends BaseDao<Menu> {

    public Page getAllMenu(int pageNo, int pageSize) {
        String hql = "from Menu where  parentId is null  order  by porder asc";
        return pagedQuery(hql, pageNo, pageSize);
    }

    public List<Menu> getParentMenu() {
        String hql = "from Menu where parentId is null order by porder asc";
        return find(hql);
    }

    public List getChildrenMenu(Integer id) {
        String hql = "from Menu where parentId ="+id+" order by corder asc";
        return find(hql);
    }

    public List<Menu> findMenuByModule( String module) {
        String hql = "from Menu where module = ?";
        return find(hql,new Object[]{module});
    }

    public  List<Menu> findMenuBySubModule( String subModule) {
        String hql = "from Menu where subModule = ?";
        return find(hql,new Object[]{subModule});
    }
}
